﻿namespace Homework03
{
    internal class Program
    {
        /// <summary>
        /// 用户输入一个整数，给出它的二进制形式
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //Todo get input from keyboard
            Console.Write("Please enter an integer:");
            int number =Convert.ToInt32(Console.ReadLine());
            // Initialize an empty string to hold the binary representation
            string binary = "";
            //Continue the loop until the number comes zero
            while (number > 0)
            {
                int reminder = number % 2;
                binary = reminder + binary;
                number = number / 2;
            }
            //if the user entered zero,the binary string would be empty,set it to "0"
            if (binary == "")
            {
                binary = "0";
            }
            //onput the binary representation of the number
            Console.WriteLine($"Binary form:{binary}");
        }
    }
}
